import request from '@/utils/request'

/**
 * 删除报表
 * @param {*} parameter
 * @returns
 */
export function deleteReportListApi (parameter) {
  return request({
    url: '/report/'+ parameter.id,
    // url: '/mock/66/report/'+ parameter.id,
    method: 'delete',
    data: parameter,
  })
}

/**
 * 更新报表
 * @param {*} parameter
 * @returns
 */
export function updateReportListApi (parameter) {
  return request({
    url: '/report/'+ parameter.id,
    // url: '/mock/66/report/'+ parameter.id,
    method: 'put',
    data: parameter,
  })
}

/**
 * 创建报表
 * @param {*} parameter
 * @returns
 */
export function addReportListApi (parameter) {
  return request({
    url: '/report',
    // url: '/mock/66/report',
    method: 'post',
    data: parameter,
  })
}

/**
 * 查询指定id报表
 * @param {*} parameter
 * @returns
 */
export function getUpdateReportListApi (parameter) {
  return request({
    url: '/report/'+ parameter.id,
    // url: '/mock/66/report/'+ parameter.id,
    method: 'get',
    data: parameter,
  })
}

/**
 * 查询报表列表
 * @param {*} parameter
 * @returns
 */
export function getReportListApi (parameter) {
  return request({
    url: '/report',
    // url: '/mock/66/report',
    method: 'get',
    params: parameter,
  })
}

/**
 * 分享报表
 * @returns
 */
export function sharingReportApi (reportId, parameter) {
  return request({
    url: '/report/'+ reportId+ '/share',
    method: 'post',
    data: parameter,
  })
}

/**
 * 取消分享报表
 * @returns
 */
export function cancelSharingReportApi (reportId) {
  return request({
    url: '/report/'+ reportId+ '/unshare',
    method: 'delete',
  })
}

/**
 * 查询报表用户列表
 */
export function getReportUserApi (reportId) {
  return request({
    url: '/report/' + reportId + '/share/users',
    method: 'get'
  })
}

/**
 * 查询公共分享报表授权KEY
 */
export function getSharedKeyApi (reportId) {
  return request({
    url: '/report/' + reportId + '/key',
    method: 'get'
  })
}


/**
 * 创建公共分享报表授权KEY
 */
export function addSharedKeyApi (reportId,token) {
  return request({
    url: '/report/' + reportId + '/key',
    method: 'post',
    data: {refreshToken: token}
  })
}

/**
 * 删除公共分享报表授权KEY
 */
export function deleteSharedKeyApi (props) {
  return request({
    url: '/report/' + props.reportId + '/key/' + props.key,
    method: 'delete'
  })
}


/**
 * 查询已关注报表列表
 */
export function getFollowingReportsApi () {
  return request({
    url: '/report/follow',
    method: 'get'
  })
}

/**
 * 查询报表关注状态
 */
export function getFollowingStatusApi (id) {
  return request({
    url: '/report/follow/' + id,
    method: 'get'
  })
}


/**
 * 添加关注
 */
export function followReportApi (id) {
  return request({
    url: '/report/follow/' + id,
    method: 'post'
  })
}


/**
 * 取消关注
 */
export function unfollowReportApi (id) {
  return request({
    url: '/report/follow/' + id,
    method: 'delete'
  })
}
